// c++初始化列表示例
#include <iostream>
using namespace std;

class Score
{ 
public:
    float math;
    float history;

    Score(float m = 0,float h = 0):math(m),history(h) 
    {
        cout << "构造了score" <<endl;
    }
};

class Student
{
    int age;            //年龄，普通类成员
    const string name;  //姓名：const型类成员
    Score score;        //各科成绩，类对象成员

public:
    Student(int a,string name,Score &s)
        :age(a),name(name),score(s) //初始化列表
    {

    }

    void showinfo() const
    {
        cout << score.math << endl;
        cout << score.history << endl;
    }
};

int main(int argc, char const *argv[])
{
    Score score(90,89);
    Student jack(21,"jack",score); 
    jack.showinfo();

    return 0;
}
